import time
from machine import Pin

buttonPin = Pin(23, Pin.IN)
ledPin = Pin(2, Pin.OUT)

while True:
    if buttonPin.value() == 0:
        print("按下了")
        ledPin.value(1)
    elif buttonPin.value() == 1:
        print("没按下")
        ledPin.value(0)
    time.sleep(0.5)
